package com.springboot.mail.common;


import com.springboot.mail.common.bean.MyResult;
import com.springboot.mail.common.constant.ResultBaseEnum;

/**
 * @data 2019/6/4 15:06
 * @classDesc: 功能描述:
 */
public class ResultUtil {

    /*
       success
     */
    public static <T> MyResult<T> success(T data) {
        return new MyResult<>(true, null, null, data);
    }
    public static <T> MyResult<T> success() {
        return success(null);
    }


    /*
        error
     */

    public static <T> MyResult<T> error(String errorCode, String errorMsg, T data) {
        return new MyResult<>(false, errorCode, errorMsg, data);
    }

    public static <T> MyResult<T> error(ResultBaseEnum resultEnum, T data) {
        return error(resultEnum.getCode(), resultEnum.getMsg(), data);
    }

    public static <T> MyResult<T> error(ResultBaseEnum resultEnum) {
        return error(resultEnum, null);
    }

    public static <T> MyResult<T> error(String msg) {
        return error("4000", msg, null);
    }

}
